package com.lqs.sofp.service.impl;

import com.lqs.sofp.dao.TextInfoDao;
import com.lqs.sofp.dao.impl.TextInfoDaolmpl;
import com.lqs.sofp.entity.Text;
import com.lqs.sofp.service.TextService;

import java.util.ArrayList;
import java.util.List;

/**
 * @author cj
 */
public class TextServiceImpl implements TextService {
    @Override
    public Boolean submitText(Text text) {
        TextInfoDao textInfo = new TextInfoDaolmpl();
        Boolean success = textInfo.update(text);
        return success;
    }

    @Override
    public ArrayList<Text> getText() {
        List<Text> textList = new ArrayList<>();
        TextInfoDao textInfo = new TextInfoDaolmpl();
        textList = textInfo.selectAll();
        return (ArrayList<Text>) textList;
    }

    @Override
    public ArrayList<Text> getText(String userName) {
        List<Text> textList = new ArrayList<>();
        TextInfoDao textInfo = new TextInfoDaolmpl();
        textList = textInfo.select(userName);
        return (ArrayList<Text>) textList;
    }

    @Override
    public Boolean deleteText(Text text) {
        TextInfoDao textInfo = new TextInfoDaolmpl();
        Boolean success = textInfo.delete(text);
        return success;
    }
}
